﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using Telerik.Web.UI;
using KPIS.GERP.GIMS.DAL;
using KPIS.GERP.GIMS.MODEL;

namespace KPIS.GERP.GIMS.APP.APP_UI.Edit_Form
{
    public partial class ICM_Requisition_Cut_Stock : System.Web.UI.Page
    {
        Common.Main cn = new Common.Main();
        M_Requisition m_request = new M_Requisition();
        D_Requisition d_request = new D_Requisition();
        D_Requisition_Desc d_request_desc = new D_Requisition_Desc();
        M_Requisition_Desc m_request_desc = new M_Requisition_Desc();
        D_StockMovement d_stock_movement = new D_StockMovement();
        M_StockMovement m_stock_movement = new M_StockMovement();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                pRequisitionCode.Text = Request.QueryString["Requsition_Code"]; //"RQ2554-02-00047";
                LoadGrid();
                LoadToObject();
                grdRequisition.DataBind();
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
          //  m_stock_movement.movement_code = fncGenerate_MovementCode();
          //  m_stock_movement.to_job_site_seq = Convert.ToInt32(hJobSiteSeq.Text);
          //  m_stock_movement.icm_res_item_seq = Convert.ToInt32(hInventoryItem.Text);
          //  m_stock_movement.request_quantity = Convert.ToDouble(hRequestQuantity.Text);
          //  //m_stock_movement.cutstock_real_quantity =RadTextBox1.Text;
          ////  m_stock_movement.icm_receive_code_from_to = "";
            
          //  m_stock_movement.created_by = cn.UserID;
          //  m_stock_movement.created_when = DateTime.Now;
                
        }
        protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            LoadGrid();
            grdRequisition.Rebind();
        }
        protected void btnCancel_Click(object sender, EventArgs e)
        {
        }
        protected void grdRequisition_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            LoadGrid();
        }

        private void LoadGrid()
        {
            grdRequisition.DataSource = d_stock_movement.GetListForCutStock(pRequisitionCode.Text);
        }
        private void LoadToObject()
        {
            M_Requisition info = d_request.GetListFillBySeq(pRequisitionCode.Text);
            pRequisitionCode.Text = info.requisition_code;
            pRequisitionDate.Text = info.requisition_date.ToShortDateString();
            pEmployeeName.Text = info.employee_name;
            pOrganizeName.Text = info.job_site_name;
            pDescriptionRequest.Text = info.description;
            pRemark.Text = info.remark;
        }
    }
}
